<?php

$success = true;
$userName = "";
$password = "";
$repass = "";
if (isset($_POST["register"])) {
    $userName = $_POST['username'];
    $password = $_POST['pass'];
    $repass = $_POST['repass'];

    $user = new user("WHERE `username` = '$userName'");
    if ($user->getUserNumRows() == 0) {
        //true
        $newMember = new user("");
        $newMember->changeValues($userName, md5($password), 0);
        $newMember->injectUser();
        $newMember = new user("WHERE `username` = '$userName'");

        $_SESSION["username"] = $newMember->getUserName();
        //echo name;

        mkdir($defaultpath."/".$newMember->getUserName(), 0, true);
        header("location: userfile.php?username=" . $newMember->getUserName()."&path=".$defaultpath."/".$newMember->getUserName());
    } else {
        $success = false;
    }
}
?>
